package com.pms.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.pms.entity.Ideacomment;
import com.pms.entity.Users;
import com.pms.service.IdeaCommentService;
import com.pms.util.GetSession;

public class IdeaComment extends HttpServlet {

	
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		
	}
	
	

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setCharacterEncoding("utf-8");
		
		String idid=request.getParameter("ideaid");
		String content=request.getParameter("content");
		System.out.println(idid+content);
		
		Users user = (Users)GetSession.getSession(request).getAttribute("user");
		System.out.println(user.getUser_id());
		Ideacomment ic=new Ideacomment();
		
		ic.setIdeaid(idid);
		ic.setContent(content);
	
		ic.setUserid(user.getUser_id());
		
		new IdeaCommentService().save(ic);
		response.sendRedirect("toIdeashow.jspx");
		
	}

}
